package com.szrt.java.day20161227.demo03;


import java.util.Arrays;
import java.util.Scanner;

import org.junit.Test;

public class ArrayAddTest03 {
	
	@Test
	public void del(){
		
		int[] oldArray = new int[]{5,4,3,2,1};
		
		Scanner sc = new Scanner(System.in);
		System.out.print(Arrays.toString(oldArray));
		System.out.println("请输入你要删除数组中第几个位置的数：");
		int numDel = sc.nextInt();
		sc.close();
		
		int[] newArray = new int[4];
		
        for(int index =0;index<numDel;index++){
			//拿到旧数组前半部分的值
			int value = oldArray[index];
			newArray[index] = value;
		}
        
        for(int index =4;index>numDel;index--){
        	int value = oldArray[index];
        	newArray[index-1] = value;
        }
        
        System.out.println("删除数组中的3前：");
        System.out.print(Arrays.toString(oldArray));
        
        System.out.println();
        System.out.println("删除数组中的3后：");
        System.out.print(Arrays.toString(newArray));
        
	}
	
}
